package enum

// <any key>: true or false
type Enum map[interface{}]bool

func New(args ...interface{}) *Enum {
	enum_inst := make(Enum)

	for _, e := range args {
		enum_inst[e] = true
	}

	return &enum_inst
}

func FromArray(arr []interface{}) *Enum {
	enum_inst := make(Enum)

	for _, e := range arr {
		enum_inst[e] = true
	}

	return &enum_inst
}

// has value by key
func (e *Enum) Has(v interface{}) bool {
	_, ok := (*e)[v] // get the enum value by key

	if !ok {
		panic("no such value for provided key")
	}

	return true

}

// get key by key?
func (e *Enum) Get(v interface{}) interface{} {
	// check v exists; none it will panic
	e.Has(v)

	return v

}

func (e *Enum) Eq(a interface{}, b interface{}) bool {
	e.Has(a)
	e.Has(b)

	if a == b {
		return true
	}

	return false
}
